"""
这边为客户端
"""
import AI_WeDo.DDPG.DDPG_Main as DDPG
import math
import AI_WeDo.Tools.Socket as soc
import AI_WeDo.Tools.Message_Class as mess

action_dim=[2,1]    # 连续2，离散1
action_bound=10/180*math.pi     # 动作取值范围
state_dim=5     # 输入特征维度
state_dim_2=0       # 第二层输入特征的维度
n_friend=1  # 我方数量
n_enemy=1   # 对手数量

class Env():
    def __init__(self, n_friend, n_enemy):
        print('开始连接网络。。。')
        self.socket=soc.Socket_Client(host='210.45.252.204')
        self.socket.Connect()
        print('环境前置准备中。。。')
        command=mess.Send_mess()
        command.set_command(0)
        command.set_data('n_friend({0})'.format(n_friend))
        command.set_data('n_enemy({0})'.format(n_enemy))
        self.socket.Send(command)
        print('环境连接完成')

    def reset(self):
        print('环境初始化')
        message=mess.Send_mess()
        message.set_command(1)
        ob=self.socket.Send_Receive(message)
        return ob

    def FirstStep(self):
        pass
    def Step(self):
        pass
    def Render(self):
        pass

if __name__=='__main__':
    algorithm=DDPG.ddpg(action_dim,state_dim,action_bound)
    Envm = Env(n_friend, n_enemy)
    #algorithm.main(Envm)
    a=Envm.reset()
    print(a)
    li=list(eval(a))
    print(str(li))